package com.cn.jx.manager.service.query.Impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Service;

import com.cn.jx.manager.service.query.IDocumentServiceQry;
import com.jx.enumType.ApplyEnum;
import com.jx.enumType.XmlTypeEnum;
import com.jx.fileUtil.xml.Impl.SaxXml;
import com.jx.model.Dict;
import com.jx.model.RedisSetEntity;
import com.jx.util.MapObject;

/**
 * 
 * @author 姜旭
 * @version v1.11.20.2019
 * @since 
 * <p>创建时间：2019年11月29日
 * <p>功能描述：<p>IDocumentService  文档类的
 * <p>官方网站：management/admin/index
 * <p>邮箱地址：524577360@qq.com
 */
@Service("documentServiceQry") 
public class DocumentServiceImplQry implements IDocumentServiceQry {
	
	/**
	 * url概览
	 */
	@Override
	public MapObject getUrlOverView() {
		List<MapObject> listLogin=SaxXml.getXmlToMap(XmlTypeEnum.LINK_ADDR);
		MapObject mmb=MapObject.getInstance();
		
		listLogin.forEach(mo->{
			String k=(String) mo.get("parent");
			String parames=(String) mo.get("parames");
			parames=parames.replace("^", "&nbsp;");
			parames=parames.replace("_", "</br>");
			mo.put("parames", parames);
			if(mmb.containsKey(k)){
				@SuppressWarnings("unchecked")
				List<MapObject> ltext=(List<MapObject>) mmb.get(k);
				ltext.add(mo);
				mmb.put(k, ltext);
			}else{
				List<MapObject> lt=new ArrayList<MapObject>();
				lt.add(mo);
				mmb.put(k, lt);
			}
		});
		return mmb;
	}

	@Override
	public Map<String, RedisSetEntity> getRedisUse() {
		Map<String, RedisSetEntity> mp=new HashMap<String, RedisSetEntity>();
		String redisDesc1="<p>key =\"roleService\"</p>"
				+ "<p>value =\"'getRoleById='.concat(#id)\"</p>"
				+ "<p>rTime = RedisTime.SIX_HOURS</p>"
				+ "<p>cls = Role.class</p>";
		String remark1="角色表对象的缓存，每一个角色对象一个缓存。对象更新操作需要清理缓存！";
		RedisSetEntity pe1=RedisSetEntity.getInstance("RoleServiceImplQry", "getRoleById", redisDesc1,remark1);
		mp.put("角色对象缓存", pe1);
		return mp;
	}

	@Override
	public Map<String, Set<Dict>> getDictDesign() {
		Map<String, Set<Dict>> mp=new HashMap<String, Set<Dict>>();
		mp.put("所属应用", ApplyEnum.getAllEnum());
		return mp;
	}

}
